package com.neuedu.servlet.employee;


import com.google.gson.Gson;
import com.neuedu.pojo.Employee;
import com.neuedu.pojo.PageResult;
import com.neuedu.service.EmployeeService;
import com.neuedu.service.Imp.EmployeeServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

@WebServlet("/selectEmp")
public class EmployeeServlet extends HttpServlet {
    private EmployeeService employeeService = new EmployeeServiceImp();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        String account = req.getParameter("account");
        String nickname = req.getParameter("nickname");
        String telephone = req.getParameter("telephone");

        PageResult<List<Employee>> employees = employeeService.getEmp(currentPage,pageSize,account,nickname,telephone);



        Gson gson = new Gson();
        String json = gson.toJson(employees);

        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
